home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re Save Command.4 < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  2.3 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Save Command
  2. Sent:        6/25/96 3:10 PM
  3. Received:    6/25/96 3:53 PM
  4. From:        John Casey, jcasey@ncs-ssc.com
  5. Reply-To:    ODF Interest, ODF-Interest@cilabs.org
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@cilabs.
  7.  
  8. >I hope others will weigh in with their opinions. Unfortunately, I don't 
  9. >think there is currently a clean way to do this. On the Mac, You could 
  10. >make up a dummy menu event record and call ODDispatcher::Dispatch(). 
  11. >You'd need to set the "what" field to kODEvtMenu, ask the current menu 
  12. >bar for the menu and item number corresponding to the save command, and 
  13. >put them in the high and low word of the message field, respectively. 
  14. >Ouch!
  15.  
  16. I attempted to implement your suggestion; however, I still could not get 
  17. it to work.  Below is a code sniplet of my command's DoIt method.
  18.  
  19. void CSaveCmd::DoIt(Environment* ev)
  20. {
  21.     // Create the platform event
  22.     FW_CFrame* frame = this->GetFrame(ev);
  23.     FW_ASSERT(frame != kODNULL);
  24.     ODEventData eventData;
  25.     FW_CPart* part = frame->GetPart(ev);
  26.     FW_ASSERT(part != kODNULL);
  27. #ifdef FW_BUILD_MAC
  28.     FW_CMenuBar* menuBar = part->GetMenuBar(ev);
  29.     FW_ASSERT(menuBar != kODNULL);
  30.     FW_CAcquiredODMenuBar aqODMenuBar = menuBar->AcquireODMenuBar(ev);
  31.     FW_ASSERT(aqODMenuBar != kODNULL);
  32.     ODMenuID menuID;
  33.     ODMenuItemID menuItem;
  34.     aqODMenuBar->GetMenuAndItem(ev, kODCommandSave, &menuID, &menuItem);
  35.     eventData.what = kODEvtMenu;
  36.     eventData.message  = menuID << 16;
  37.     eventData.message |= menuItem;
  38. #endif
  39. #ifdef FW_BUILD_WIN
  40.     eventData.message = kODEvtMenu;
  41.     eventData.wParam = kODCommandSave;
  42. #endif
  43.  
  44.     // Dispatch the "Save" command
  45.     ODSession* odSession = part->GetSession(ev);
  46.     FW_ASSERT(odSession != kODNULL);
  47.     ODDispatcher* odDispatcher = odSession->GetDispatcher(ev);
  48.     FW_ASSERT(odDispatcher != kODNULL);
  49.     odDispatcher->Dispatch(ev, &eventData);
  50. }
  51.  
  52.  
  53. ========================================================================
  54. John Casey                         email: jcasey@ncs-ssc.com
  55. Vice President                     web:   http://www.ncs-ssc.com
  56. Nation Computer Services           voice: (804) 378-8917
  57.                                    fax:   (601) 689-8130
  58. ========================================================================
  59.